wayland: Don't ignore wl_keyboard.leave if surface is gone
authorJonas Ådahl <jadahl@gmail.com>
Tue, 6 Oct 2015 06:30:28 +0000 (14:30 +0800)
committerJonas Ådahl <jadahl@gmail.com>
Wed, 7 Oct 2015 04:28:39 +0000 (12:28 +0800)
keyboard_handle_leave() might be called with a NULL surface resource
(for example if the surface was destroyed after the event was sent). If
so, we should still deal with the keyboard focus lost event, otherwise
we will both leak (the keyboard_focus GdkWindow reference) and miss
stopping the key repeat timer.

https://bugzilla.gnome.org/show_bug.cgi?id=755927

gdk/wayland/gdkdevice-wayland.c

index 92548858c1c6f60efdb490520c07d170c5af6adc..b6e3fd01937807e2939b805e9eda0d12aa8d3d12 100644 (file)
@@ -1191,15 +1191,14 @@ keyboard_handle_leave (void               *data,
   GdkEvent *event;
   GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display);
 
-  if (!surface)
-    return;
-
-  if (!GDK_IS_WINDOW (wl_surface_get_user_data (surface)))
-    return;
-
   if (!device->keyboard_focus)
     return;
 
+  /* gdk_window_is_destroyed() might already return TRUE for
+   * device->keyboard_focus here, which would happen if we destroyed the
+   * window before loosing keyboard focus.
+   */
+
   stop_key_repeat (device);
 
   _gdk_wayland_display_update_serial (display, serial);